package com.hd.service.test;

import java.util.Calendar;
import java.util.List;

import com.hd.common.DataPage;
import com.hd.persistence.model.AssignRecord;
import com.hd.utils.HdException;

public class AssignRecordManagerTestCase extends BaseTest {
	
	//保存实体
//	public void testSaveAssignRecord() throws HdException {
//		for ( int i = 0; i < 20; i++ ) {
//			AssignRecord assignRecord = new AssignRecord();
//			assignRecord.setUnitName("单位名称" + i);
//			assignRecord.setUnitForShort("dwjc" + i);
//			assignRecord.setContactWay("0510-85910687");
//			assignRecord.setAddress("无锡市");
//			assignRecord.setContactor("联系人" + i);
//			assignRecord.setMachineNo("00000" + i);
//			assignRecord.setMachineModel("OOXX0");
//			assignRecord.setWorkday(new Date());
//			assignRecord.setRepairman("维修员" + i);
//			assignRecord.setContent("随便耍耍");
//			assignRecord.setCompleteTime(123);
//			assignRecord.setReachTime(456);
//			assignRecord.setCreateTimestamp(789);
//			repairManager.saveAssignRecord(assignRecord);
//		}
//	}
	
	//分页查询
//	public void testPageQueryAssignRecords() throws HdException {
//		DataPage<AssignRecord> dataPage = repairManager.pageQuryAssignRecords(1, 10);
//		System.out.println("查询总数为:" + dataPage.getTotalCount());
//		List<AssignRecord> assignRecords = dataPage.getData();
//		for ( AssignRecord assignRecord : assignRecords ) {
//			System.out.println(assignRecord.getAssignRecordId() + " " + assignRecord.getMachineModel());
//		}
//	}

	//根据条件分页查询
	public void testPageQueryAssignRecords2() throws HdException {
		Calendar c = Calendar.getInstance();
		c.set(Calendar.MONTH, 2);
		c.set(Calendar.DAY_OF_MONTH, 25);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.SECOND, 0);
		c.set(Calendar.MILLISECOND, 0);
		DataPage<AssignRecord> dataPage = repairManager.pageQueryAssignRecords("单位名称0", "dwjc0", "OOXX0", "维修员0", c.getTime(), 1, 100);
		System.out.println("查询总数为:" + dataPage.getTotalCount());
		List<AssignRecord> assignRecords = dataPage.getData();
		for ( AssignRecord assignRecord : assignRecords ) {
			System.out.println(assignRecord.getAssignRecordId() + " " + assignRecord.getMachineModel());
		}
	}
	
}
